<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script>
			window.onload = function(){
				//获取ul
				var u1 = document.getElementById("u1");
				//点击按钮新建一个超链接
				var btn01 = document.getElementById("btn01");
				btn01.onclick = function(){
					var li = document.createElement("li");
					li.innerHTML = "<a href='javascript:;' class='link'>新建的超链接</a>";
					u1.appendChild(li);
					
				};
				
				
				
				
				//为所有的a绑定一个单机响应函数
				var allA = document.getElementsByTagName("a");
				
//					for(var i=0; i<allA.length; i++){
//						allA[i].onclick = function(){
//							alert("我是a的单机响应函数");
//					};
					u1.onclick = function(event){
						event = event || window.event;
						
						if(event.target.className == "link"){
							alert("我是ul的单机响应函数");
						}
						
					};
				
			};
		</script>
	</head>
	<body>
		<button id="btn01">按钮</button>
		<ul id="u1">
			<li><a href="javascript:;" class="link">超链接一</a></li>
			<li><a href="javascript:;" class="link">超链接二</a></li>
			<li><a href="javascript:;" class="link">超链接三</a></li>
		</ul>
	</body>
</html>
